
import './App.css';
import React, { useEffect } from 'react';
import {
  BrowserRouter,
  Route,
  Switch
} from 'react-router-dom'

import { Redirect } from 'react-router-dom/cjs/react-router-dom.min';
import FingerprintJS from '@fingerprintjs/fingerprintjs'
import DeviceID from './utils/deviceId';
// import LaunchMode1 from './pages/Launch/LaunchMode1';
import LaunchMode2 from './pages/Launch/LaunchMode2';
import LaunchMode2Download from './pages/Launch/LaunchMode2Download';

function App() {

  //初始化指纹
  useEffect(() => {

    //初始化 设备id
    if (!DeviceID.isValidVistorId()) {
      //初始化
      const fpPromise = FingerprintJS.load()

      //获取设备id
      fpPromise
        .then(fp => fp.get())
        .then(result => {
          DeviceID.saveVisitorId(result.visitorId)
          console.log("启动初始化 fingerprint: " + result.visitorId)

          //保存aduid
          //doSaveAduid()
        })
    } else {
      //保存aduid
      //doSaveAduid()
    }

    //监听安装事件
    //AddHomeEvent.addBeforeInstallPromptEventListener()

  }, [])

  console.log("=========base path: " + process.env.REACT_APP_BASE_PATH)

  return (
    <BrowserRouter basename="/h5grizzlycashgp">
      <div className="AppRoot">
        <div className="App">

          <Switch>

            {/* <Route path='/launch1' ><LaunchMode1 /></Route> */}
            <Route path='/download' ><LaunchMode2Download /></Route>
            <Route path='/launch' ><LaunchMode2 /></Route>

            {/* 直接去启动页 */}
            <Redirect to='/launch'></Redirect>

          </Switch>
        </div>
      </div>
    </BrowserRouter>
  );
}

export default App;
